//
//  S1mpl3MoreInfoViewController.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "S1mpl3MoreInfoViewController.h"
#import "BaseLabel.h"
#import "FitHeader.h"
#import "TabBarController.h"
#import "Model.h"

@interface S1mpl3MoreInfoViewController ()

@end

@implementation S1mpl3MoreInfoViewController

-(void)viewWillAppear:(BOOL)animated{
    [[TabBarController shareInstance] remainButtonOfPlay:YES];
    
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:0.84 green:0.23 blue:0 alpha:1]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[Model shareInstance].TitleColor, NSForegroundColorAttributeName, nil]];
    //    self.navigationController.navigationBar.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated
{
    [[TabBarController shareInstance] remainButtonOfPlay:NO];
}

-(void)loadView{
    [super loadView];
    NSString *tags = [_dataSourceDic objectForKey:@"tags"];
    NSString *intro = [_dataSourceDic objectForKey:@"intro"];
    if (tags.length != 0) {
        BaseLabel *titleLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(10 * FITWidth, 20 * FITHeight, 50 * FITWidth, 30 * FITHeight)];
        titleLabel.text = @"标签:";
        titleLabel.textColor = [UIColor grayColor];
        titleLabel.textAlignment = 1;
        [titleLabel setFontSize:15];
        [self.view addSubview:titleLabel];
        NSArray *tagsArray = [tags componentsSeparatedByString:@","];
        for (NSInteger i = 0; i < tagsArray.count; i++) {
            BaseLabel *label = [[BaseLabel alloc] initWithFrame:CGRectMake(titleLabel.frame.origin.x + titleLabel.frame.size.width + i % 3 * 80 * FITWidth, i / 3 * 35 * FITHeight + titleLabel.frame.origin.y, 75 * FITWidth, 30 * FITHeight)];
            label.textAlignment = 1;
            label.layer.cornerRadius = 10 * FITHeight;
            label.layer.borderWidth = .5;
            label.layer.borderColor = [UIColor lightGrayColor].CGColor;
            label.text = tagsArray[i];
            [label setFontSize:15];
            label.textColor = [UIColor lightGrayColor];
            [self.view addSubview:label];
        }
        BaseLabel *introLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(10 * FITWidth, 20 * FITHeight + (tagsArray.count / 3 + 1) * 35 * FITHeight,  50 * FITWidth, 30 * FITHeight)];
        introLabel.text = @"简介:";
        introLabel.textColor = [UIColor grayColor];
        introLabel.textAlignment = 1;
        [introLabel setFontSize:15];
        [self.view addSubview:introLabel];
        
        BaseLabel *contentLabel = [[BaseLabel alloc] init];
        contentLabel.textColor = [UIColor grayColor];
        contentLabel.numberOfLines = 0;
        [contentLabel setFontSize:14];
        CGRect rect = [intro boundingRectWithSize:CGSizeMake(350 * FITWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
        contentLabel.frame = CGRectMake(10 * FITWidth, introLabel.frame.origin.y + introLabel.frame.size.height, 350 * FITWidth, ceill(rect.size.height + 1));
        contentLabel.text = intro;
        [self.view addSubview:contentLabel];

    }else{
        BaseLabel *introLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(10 * FITWidth, 20 * FITHeight,  50 * FITWidth, 30 * FITHeight)];
        introLabel.text = @"简介:";
        introLabel.textColor = [UIColor grayColor];
        introLabel.textAlignment = 1;
        [introLabel setFontSize:15];
        [self.view addSubview:introLabel];
        
        BaseLabel *contentLabel = [[BaseLabel alloc] init];
        contentLabel.textColor = [UIColor grayColor];
        [contentLabel setFontSize:14];
        CGRect rect = [intro boundingRectWithSize:CGSizeMake(350 * FITWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
        contentLabel.frame = CGRectMake(10 * FITWidth, introLabel.frame.origin.y + introLabel.frame.size.height, 350 * FITWidth, ceill(rect.size.height + 1));
        contentLabel.text = intro;
        [self.view addSubview:contentLabel];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
